/*
 * Copyright (c) 2011 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.snj.visangedu.calendar;

import android.content.SharedPreferences;

/**
 * @author AA@google.com (Your Name Here)
 *
 */
public class Util_Preferences {
  private SharedPreferences preferences;

  public Util_Preferences(SharedPreferences share) {
    preferences = share;
  }

  public String Read(String key, String default_value) {
    return preferences.getString(key, default_value);
  }

  public int Read(String key, int default_value) {
    return preferences.getInt(key, default_value);
  }

  public long Read(String key, long default_value) {
    return preferences.getLong(key, default_value);
  }

  public float Read(String key, float default_value) {
    return preferences.getFloat(key, default_value);
  }

  public boolean Read(String key, boolean default_value) {
    return preferences.getBoolean(key, default_value);
  }

  public void Write(String key, String value) {
    if (value == null) value = "";
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString(key, value);
    editor.commit();
  }

  public void Write(String key, int value) {
    SharedPreferences.Editor editor = preferences.edit();
    editor.putInt(key, value);
    editor.commit();
  }

  public void Write(String key, long value) {
    SharedPreferences.Editor editor = preferences.edit();
    editor.putLong(key, value);
    editor.commit();
  }

  public void Write(String key, float value) {
    SharedPreferences.Editor editor = preferences.edit();
    editor.putFloat(key, value);
    editor.commit();
  }

  public void Write(String key, boolean value) {
    SharedPreferences.Editor editor = preferences.edit();
    editor.putBoolean(key, value);
    editor.commit();
  }

  public void Reset() {
    SharedPreferences.Editor editor = preferences.edit();
    editor.clear();
    editor.commit();
  }

}
